#pragma once
#include"Buffer.h"
#include <stdlib.h>
#include<string.h>
#include<strings.h>
#include"TcpConnection.h"
enum HttpStatusCode
{   Unknow,
    OK = 200, //成功
    MovePermanently=301, //永九重定向
    MoveTemporarily=302, //临时重定向
    BadRequest=400, //客户端发起的错误请求
    NotFound=404 //发起的请求找不到
};

struct ResponseHeader
{
    char key[32];
    char value[128];
};

typedef void (*responseBody)(const char* filename,struct Buffer* sendbuffer,int socket);

struct HttpResponse
{
    // 状态行 状态码 状态描述
    enum HttpStatusCode httpStatusCode;
    char statusMsg[128];
    char filename[128];

    //响应头 -键值对
    struct ResponseHeader* headers;
    // 判断有好多行数据
    int headerNum;

    responseBody sendDataFunc;

};
// 初始化
struct HttpResponse* httpResponseInit();

// 销毁函数

void HttpResponseestory(struct HttpResponse* httpResponse);
// 添加响应头

void addResponseHeader(struct HttpResponse* httpResponse,const char* key,const char* value);
// 组织http的响应数据
void httpResponsePrepareMsg(struct HttpResponse* httpResponse,struct Buffer* sendbuffer,int socket);